// Learn TypeScript:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

import { privacyChannel } from "./privacyChannel";

const { ccclass, property } = cc._decorator;

@ccclass
export default class privacyButton extends cc.Component {
    protected onLoad(): void {
        if (privacyChannel.channel == 'ks' || privacyChannel.channel == 'ks1') {
            this.node.active = false
        }
    }

    onClick() {
        cc.resources.load('privacy/privacyWin', cc.Prefab, (err, data: cc.Prefab) => {
            if (err) {
                console.error(err);
                return;
            }

            console.log("注入成功")
            let node = cc.instantiate(data);
            cc.director.getScene().getChildByName('Canvas').getChildByName("UI").addChild(node);
        });
    }

    // update (dt) {}
}
